package cn.homework.day08;

import java.util.*;
import java.util.stream.Collectors;

public class Test02 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("adc", "物理英雄");
        map.put("apc", "魔法英雄");
        map.put("t", "坦克");
        System.out.println(map);
        //对这个HashMap进行反转，key变成value,value变成key
        //获取key集合
        Set<String> s1 = map.keySet();
        List<String> collect1 = s1.stream().collect(Collectors.toList());
        System.out.println(collect1);
        //获取value
        Collection<String> s2 = map.values();
        List<String> collect2 = s2.stream().collect(Collectors.toList());
        System.out.println(collect2);
        for (int i = 0; i < collect1.size(); i++) {
            map.put(collect2.get(i),collect1.get(i));
            map.remove(collect1.get(i));
        }
        System.out.println(map);

    }
}
